import Vue from 'vue'
// 引入css样式文件
import 'normalize.css/normalize.css' // A modern alternative to CSS resets
// 引入ElementUI 相关的资源
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// 引入ElementUI的语言包
// import locale from 'element-ui/lib/locale/lang/en'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n
// 引入全局样式文件
import '@/styles/index.scss' // global css
// 引入根组件
import App from './App'
// 引入vuex
import store from './store'
// 引入路由router
import router from './router'
// 加载icon 图片
import '@/icons' // icon
// 加载路由守卫----> 实现权限控制
import '@/permission' // permission control
import i18n from '@/lang'
Vue.directive('focus', {
  inserted: function(el, bindings) {
    console.log(el, 'xxxxxxxxxx')
    console.log(bindings, 'bindingsbindingsbindingsbindingsbindings')
    console.log(bindings.value)
    el.style.backgroundColor = 'yellowGreen'
    el.focus()
  }
})
Vue.directive('allow', {
  inserted: function(el, bindings) {
    const points = store.state.user.userInfo.roles.points
    console.log(points, 'bindingsbindingsbindingsbindingsbindings')
    console.log(bindings.value)
    if (points.includes(bindings.value)) {
      console.log('有权限访问次按钮', bindings.value)
    } else {
      el.style.display = 'none'
    }
  }
})
/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */

// 注册ElementUI并配置语言包
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
Vue.use(ElementUI)
//  定义全局组件的格式
// import MyPlugin from '@/components'
// Vue.use(MyPlugin)
// Vue.config.productionTip = false
// import PageTools from './components/PageTools'
// const MyPlugin = {
//   install(Vue) {
//     console.log('install.....', obj)
//     Vue.component('PageTools', PageTools)
//   }
// }
// Vue.use(MyPlugin)
import Components from '@/components'
Vue.use(Components)

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
